package com.qianji.petmall.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @author liang zai
 * @date 2022/4/24 15:32
 * @description
 */
@Configuration
public class PetmallSessionConfig {
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
        //放大作用域
        serializer.setDomainName("petmall.com");
        serializer.setCookieName("GULISESSION");
        serializer.setCookieMaxAge(60*60*24*7);
        return serializer;
    }
    //使用redis序列化
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new GenericJackson2JsonRedisSerializer();
    }
}
